[XEN][POWERPC] Clean up debug/traceback/trapping logic
authorHollis Blanchard <hollisb@us.ibm.com>
Thu, 30 Nov 2006 21:26:55 +0000 (15:26 -0600)
committerHollis Blanchard <hollisb@us.ibm.com>
Thu, 30 Nov 2006 21:26:55 +0000 (15:26 -0600)
This patch tries to sort out all the debugging mechanisms we have
available to us.
Signed-off-by: Jimi Xenidis <jimix@watson.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
16 files changed:
xen/arch/powerpc/backtrace.c
xen/arch/powerpc/exceptions.c
xen/arch/powerpc/mm.c
xen/arch/powerpc/powerpc64/ppc970.c
xen/arch/powerpc/powerpc64/scom.h [new file with mode: 0644]
xen/arch/powerpc/powerpc64/traps.c
xen/arch/powerpc/setup.c
xen/arch/powerpc/smp.c
xen/arch/powerpc/time.c
xen/arch/powerpc/usercopy.c
xen/include/asm-powerpc/debugger.h
xen/include/asm-powerpc/flushtlb.h
xen/include/asm-powerpc/misc.h [deleted file]
xen/include/asm-powerpc/mm.h
xen/include/asm-powerpc/page.h
xen/include/asm-powerpc/processor.h

index 0ea2b679de93a5520070b318aad88f01d324af0f..02333bb2e40e5710c8d8944d620e2eb1d2da234c 100644 (file)
@@ -14,6 +14,7 @@
 #include <xen/console.h>
 #include <xen/sched.h>
 #include <xen/symbols.h>
+#include <asm/debugger.h>
 
 static char namebuf[KSYM_NAME_LEN+1];
 
@@ -192,6 +193,19 @@ void show_backtrace(ulong sp, ulong lr, ulong pc)
     console_end_sync();
 }
 
+void show_backtrace_regs(struct cpu_user_regs *regs)
+{
+    console_start_sync();
+    
+    show_registers(regs);
+    printk("dar 0x%016lx, dsisr 0x%08x\n", mfdar(), mfdsisr());
+    printk("hid4 0x%016lx\n", regs->hid4);
+    printk("---[ backtrace ]---\n");
+    show_backtrace(regs->gprs[1], regs->lr, regs->pc);
+
+    console_end_sync();
+}
+
 void __warn(char *file, int line)
 {
     ulong sp;
@@ -202,9 +216,7 @@ void __warn(char *file, int line)
 
     sp = (ulong)__builtin_frame_address(0);
     lr = (ulong)__builtin_return_address(0);
-
     backtrace(sp, lr, lr);
+
     console_end_sync();
 }
-
-    
index 3ba5dd07253e211183cfccdcafc03ed03cfab9a9..136b47c6401aca44512a3d8ab7c89597768e926b 100644 (file)
 #include <xen/serial.h>
 #include <xen/gdbstub.h>
 #include <xen/console.h>
+#include <xen/shutdown.h>
 #include <asm/time.h>
 #include <asm/processor.h>
+#include <asm/debugger.h>
 
 #undef DEBUG
 
@@ -56,25 +58,19 @@ void do_dec(struct cpu_user_regs *regs)
 
 void program_exception(struct cpu_user_regs *regs, unsigned long cookie)
 {
-#ifdef CRASH_DEBUG
-    __trap_to_gdb(regs, cookie);
-#else /* CRASH_DEBUG */
-    int recover = 0;
-
-    console_start_sync();
-
-    show_registers(regs);
-    printk("dar 0x%016lx, dsisr 0x%08x\n", mfdar(), mfdsisr());
-    printk("hid4 0x%016lx\n", regs->hid4);
-    printk("---[ backtrace ]---\n");
-    show_backtrace(regs->gprs[1], regs->lr, regs->pc);
-
-    if (cookie == 0x200)
-        recover = cpu_machinecheck(regs);
+    if (cookie == 0x200) {
+        if (cpu_machinecheck(regs))
+            return;
 
-    if (!recover)
-        panic("%s: 0x%lx\n", __func__, cookie);
-
-    console_end_sync();
+        printk("%s: machine check\n", __func__);
+    } else {
+#ifdef CRASH_DEBUG
+        if (__trap_to_gdb(regs, cookie) == 0)
+            return;
 #endif /* CRASH_DEBUG */
+
+        printk("%s: type: 0x%lx\n", __func__, cookie);
+        show_backtrace_regs(regs);
+    }
+    machine_halt();
 }
index 1df18669d3bae6bcc655d5bc1eb76b4005bb49e7..a71bb8c2f877b4007e0a782992f0c8c3d36459ef 100644 (file)
@@ -25,7 +25,6 @@
 #include <xen/kernel.h>
 #include <xen/sched.h>
 #include <xen/perfc.h>
-#include <asm/misc.h>
 #include <asm/init.h>
 #include <asm/page.h>
 
index e59571bd35258d5745345849606c15316c89ec82..eacbf4ea0f78a0759546a0980ac254b1145f23d9 100644 (file)
@@ -30,6 +30,7 @@
 #include <asm/powerpc64/procarea.h>
 #include <asm/powerpc64/processor.h>
 #include <asm/powerpc64/ppc970-hid.h>
+#include "scom.h"
 
 #undef DEBUG
 #undef SERIALIZE
diff --git a/xen/arch/powerpc/powerpc64/scom.h b/xen/arch/powerpc/powerpc64/scom.h
new file mode 100644 (file)
index 0000000..a68651f
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Copyright (C) IBM Corp. 2006
+ *
+ * Authors: Jimi Xenidis <jimix@watson.ibm.com>
+ */
+
+#ifndef _ARCH_POWERPC_POWERPC64_SCOM_H_
+#define _ARCH_POWERPC_POWERPC64_SCOM_H_
+
+extern void cpu_scom_init(void);
+int cpu_scom_read(unsigned int addr, unsigned long *d);
+int cpu_scom_write(unsigned int addr, unsigned long d);
+void cpu_scom_AMCR(void);
+
+/* SCOMC addresses are 16bit but we are given 24 bits in the
+ * books. The low oerder 8 bits are some kinda parity thin and should
+ * be ignored */
+#define SCOM_AMC_REG       0x022601
+#define SCOM_AMC_AND_MASK  0x022700
+#define SCOM_AMC_OR_MASK   0x022800
+#define SCOM_CMCE          0x030901
+#define SCOM_PMCR          0x400801
+#define SCOM_PTSR          0x408001
+
+#endif
index e1945faa2799af498cb3dca69c5fa95762550f91..de29215d0693bde6cd2ccbda6cf8bf05c8c490e3 100644 (file)
@@ -48,7 +48,3 @@ void show_registers(struct cpu_user_regs *regs)
     console_end_sync();
 }
 
-void show_execution_state(struct cpu_user_regs *regs)
-{
-    show_registers(regs);
-}
index 5c839f698ef2478dabe57f7a0825e0631c93f3cf..56908502dec9ed3c96f65cede03a5077e010b333 100644 (file)
@@ -414,7 +414,7 @@ void __init __start_xen_ppc(
 
     } else {
         /* booted by someone else that hopefully has a trap handler */
-        trap();
+        __builtin_trap();
     }
 
     __start_xen(mbi);
index 937b1c59c22d9647e61cc2ccbf9b2342324ca00c..ce3762960e452cf7b7e36ef29bd2a89f7238a63a 100644 (file)
  * Authors: Hollis Blanchard <hollisb@us.ibm.com>
  */
 
-#include <asm/misc.h>
 #include <xen/cpumask.h>
 #include <xen/smp.h>
 #include <asm/flushtlb.h>
+#include <asm/debugger.h>
 
 int smp_num_siblings = 1;
 int smp_num_cpus = 1;
index 184e07e54d90e6e2bbde6cb45179edc673b4a1f4..04eaff1595f51753c4fd8adc0d1c4bccf0e46e6c 100644 (file)
@@ -25,7 +25,7 @@
 #include <xen/sched.h>
 #include <asm/processor.h>
 #include <asm/current.h>
-#include <asm/misc.h>
+#include <asm/debugger.h>
 
 #define Dprintk(x...) printk(x)
 
index d653ed1a05702fc8c5d565d83a9ff9afff8722e0..bb96d23b3c6401c7852fd00fab1f52ddbb166c10 100644 (file)
@@ -23,6 +23,7 @@
 #include <xen/sched.h>
 #include <asm/current.h>
 #include <asm/uaccess.h>
+#include <asm/debugger.h>
 #include <public/xen.h>
 #include <public/xencomm.h>
 
index 7e284bf1d3986617f2fc3986dc2dce5268e1b827..9c9d94b02187da9fbd6263f9a1db23365048d956 100644 (file)
 #ifndef _ASM_DEBUGGER_H_
 #define _ASM_DEBUGGER_H_
 
+extern void show_backtrace_regs(struct cpu_user_regs *);
+extern void show_backtrace(ulong sp, ulong lr, ulong pc);
+
+static inline void dump_execution_state(void)
+{
+    ulong sp;
+    ulong lr;
+
+    sp = (ulong)__builtin_frame_address(0);
+    lr = (ulong)__builtin_return_address(0);
+
+    show_backtrace(sp, lr, lr);
+}
+
+static inline void debugger_trap_immediate(void)
+{
+    dump_execution_state();
+    __builtin_trap();
+}
+
+static inline void show_execution_state(struct cpu_user_regs *regs)
+{
+    show_registers(regs);
+}
+
+extern void __warn(char *file, int line);
+#define WARN() __warn(__FILE__, __LINE__)
+#define WARN_ON(_p) do { if (_p) WARN(); } while ( 0 )
+#define unimplemented() WARN()
+
+#define FORCE_CRASH() debugger_trap_immediate()
+
 #ifdef CRASH_DEBUG
 
 #include <xen/gdbstub.h>
@@ -32,8 +64,6 @@ static inline int debugger_trap_fatal(
     return vector;
 }
 
-#define debugger_trap_immediate() __asm__ __volatile__ ("trap");
-
 #else /* CRASH_DEBUG */
 
 static inline int debugger_trap_fatal(
@@ -43,17 +73,6 @@ static inline int debugger_trap_fatal(
     return vector;
 }
 
-static inline void debugger_trap_immediate(void)
-{
-    ulong sp;
-    ulong lr;
-
-    sp = (ulong)__builtin_frame_address(0);
-    lr = (ulong)__builtin_return_address(0);
-
-    show_backtrace(sp, lr, lr);
-}
-
 #endif /* CRASH_DEBUG */
 
 #endif
index c33926a3ae04aec90dcb60910fd1e0b684c9ca70..222dc08d91565ab109459ca886c308b4e3c07ee6 100644 (file)
@@ -24,7 +24,6 @@
 #include <xen/config.h>
 #include <xen/percpu.h>
 #include <xen/types.h>
-#include <asm/misc.h>
 
 /* The current time as shown by the virtual TLB clock. */
 extern u32 tlbflush_clock;
diff --git a/xen/include/asm-powerpc/misc.h b/xen/include/asm-powerpc/misc.h
deleted file mode 100644 (file)
index b3ec14d..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * Copyright (C) IBM Corp. 2005
- *
- * Authors: Hollis Blanchard <hollisb@us.ibm.com>
- */
-
-#ifndef _ASM_MISC_H_
-#define _ASM_MISC_H_
-
-static inline void unimplemented(void)
-{
-}
-
-static inline void trap(void)
-{
-    asm volatile("trap");
-}
-
-#endif
index 7d085c9dd42acf8ded7f2db12d52502e94504631..094945e2fe9a8d6e42adad90d23b1d8b30fb8518 100644 (file)
@@ -25,7 +25,6 @@
 #include <xen/list.h>
 #include <xen/types.h>
 #include <xen/mm.h>
-#include <asm/misc.h>
 #include <asm/system.h>
 #include <asm/flushtlb.h>
 #include <asm/uaccess.h>
index f3fbaeb1ad1e5f1e441c7352e5963ab5b9a52310..279cfbb2ab9443a10d73bc008a1a45267e9f470c 100644 (file)
@@ -28,7 +28,6 @@
 #ifndef __ASSEMBLY__
 
 #include <xen/config.h>
-#include <asm/misc.h>
 #include <asm/cache.h>
 
 #define PFN_DOWN(x)   ((x) >> PAGE_SHIFT)
index d7a296515498c924b9752571d20e98f7586011c4..7d15847b0920507a32b3c62d65981bbc86736036 100644 (file)
@@ -38,10 +38,7 @@ struct domain;
 struct vcpu;
 struct cpu_user_regs;
 extern int cpu_machinecheck(struct cpu_user_regs *);
-extern void cpu_scom_init(void);
 extern void show_registers(struct cpu_user_regs *);
-extern void show_execution_state(struct cpu_user_regs *);
-extern void show_backtrace(ulong sp, ulong lr, ulong pc);
 extern unsigned int cpu_extent_order(void);
 extern unsigned int cpu_default_rma_order_pages(void);
 extern int cpu_rma_valid(unsigned int log);
@@ -54,13 +51,6 @@ extern void load_cpu_sprs(struct vcpu *);
 extern void flush_segments(void);
 extern void dump_segments(int valid);
 
-/* XXX this could also land us in GDB */
-#define dump_execution_state() BUG()
-
-extern void __warn(char *file, int line);
-#define WARN() __warn(__FILE__, __LINE__)
-#define WARN_ON(_p) do { if (_p) WARN(); } while ( 0 )
-
 #define ARCH_HAS_PREFETCH
 static inline void prefetch(const void *x) {;}